/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tri.gui.view;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.tri.entity.AbstractAnimal;
import org.tri.entity.AbstractVenta;
import org.tri.entity.Animal;
import org.tri.entity.Venta;
import org.tri.form.TRIHelper;
import org.tri.gui.worker.PersistenceListener;
import org.tri.gui.worker.PersistenceWorker;
import org.tri.persistence.search.BusquedaAnimal;

/**
 *
 * @author giaco
 */
public class VentasView extends javax.swing.JDialog
                        implements PersistenceListener{

    /**Compra con la cual se trabaja*/
    AbstractVenta venta;
    /**Modelo de lista de las caravanas*/
    DefaultListModel caravanas;
    /**Notifica un error durante la persistencia*/
    boolean errorPersist;
    /**Notifica si se ha modificado la lista*/
    boolean listModified;
    /**Lista con animales eliminados*/
    ArrayList<Animal> animalesEliminados;
    
    /**
     * Creates new form VentasView
     */
    public VentasView( java.awt.Frame parent, boolean modal, AbstractVenta venta ){
        
        super( parent , modal );
        
        //seteo la venta
        this.venta = venta;
        
        initComponents();
        
        //alineo el dialogo
        setLocationRelativeTo( parent );
        
        //seteo los atributos del dialogo
        jLTipoMovimientoVenta.setText(venta.obtenerTipoMovimiento());
        SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy");
        jLFechaVenta.setText(formato.format(venta.obtenerFecha()));
        jLEstablecimientoVenta.setText(venta.obtenerEstablecimiento().getNombre());
        eLTFDestinatario.setDefaultValue(venta.getDestinatario());
        eLFTFDtaVenta.setDefaultValue(String.valueOf(venta.getNroDta()));
        eLFTFRenspaVenta.setDefaultValue(String.valueOf(venta.getRenspaDestinatario()));
        jLCategoria.setText(String.valueOf(venta.getCategoria()));
        jLCantidadAnimalesVenta.setText(String.valueOf(venta.getCantidadAnimales()));
            
        caravanas = new DefaultListModel();
        for(AbstractAnimal a: venta.obtenerAnimales())
            caravanas.addElement(a);
        jLCaravanasVenta.setModel(caravanas);
            
        //si la venta tiene asociado un dta, no le permito modificar los animales
        if(venta.getNroDta() != 0){
            jLCaravanasVenta.setEnabled( false );
            eLFTFDtaVenta.setEnabled( false );
        }
           
        listModified = false;
        
        animalesEliminados = new ArrayList<Animal>();
           
        this.pack();
        
    }//end constructor

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPMQuitar = new javax.swing.JPopupMenu();
        jMIQuitar = new javax.swing.JMenuItem();
        jPanel3 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLTipoMovimientoVenta = new javax.swing.JLabel();
        jLFechaVenta = new javax.swing.JLabel();
        jLEstablecimientoVenta = new javax.swing.JLabel();
        jLCategoria = new javax.swing.JLabel();
        jLCantidadAnimalesVenta = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jLCaravanasVenta = new javax.swing.JList();
        eLTFDestinatario = new org.tri.swing.EditableLabelTF();
        eLFTFDtaVenta = new org.tri.swing.EditableLabelFTF();
        eLFTFRenspaVenta = new org.tri.swing.EditableLabelFTF();
        jBAceptarVenta = new javax.swing.JButton();
        jLabel23 = new javax.swing.JLabel();
        jFTFAgregar = new javax.swing.JFormattedTextField();
        jBResetearVenta = new javax.swing.JButton();
        jBImprimir = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        filler9 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 32767));
        filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(32767, 0));
        filler8 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 32767));
        filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(20, 0), new java.awt.Dimension(20, 0), new java.awt.Dimension(32767, 0));

        jMIQuitar.setText("Quitar");
        jMIQuitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMIQuitarActionPerformed(evt);
            }
        });
        jPMQuitar.add(jMIQuitar);

        jPMQuitar.getAccessibleContext().setAccessibleParent(jLCaravanasVenta);

        setResizable(false);

        jPanel3.setLayout(new java.awt.GridBagLayout());

        jLabel14.setText("Tipo de Movimiento:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel14, gridBagConstraints);

        jLabel15.setText("Fecha:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel15, gridBagConstraints);

        jLabel16.setText("Establecimiento:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel16, gridBagConstraints);

        jLabel17.setText("Cantidad de Animales:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        jPanel3.add(jLabel17, gridBagConstraints);

        jLabel18.setText("Caravanas:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LAST_LINE_END;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 0, 0);
        jPanel3.add(jLabel18, gridBagConstraints);

        jLabel19.setText("Destinatario:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel19, gridBagConstraints);

        jLabel20.setText("DTA:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel20, gridBagConstraints);

        jLabel21.setText("Categoria:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel21, gridBagConstraints);

        jLabel22.setText("Renspa:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        jPanel3.add(jLabel22, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(jLTipoMovimientoVenta, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(jLFechaVenta, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(jLEstablecimientoVenta, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(jLCategoria, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(jLCantidadAnimalesVenta, gridBagConstraints);

        jScrollPane3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jScrollPane3MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jScrollPane3MouseReleased(evt);
            }
        });

        jLCaravanasVenta.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jLCaravanasVenta.setComponentPopupMenu(jPMQuitar);
        jLCaravanasVenta.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLCaravanasVentaMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLCaravanasVentaMouseReleased(evt);
            }
        });
        jScrollPane3.setViewportView(jLCaravanasVenta);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridheight = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        jPanel3.add(jScrollPane3, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(eLTFDestinatario, gridBagConstraints);
        eLTFDestinatario.makeEditable();
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(eLFTFDtaVenta, gridBagConstraints);
        eLFTFDtaVenta.makeEditable(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new DecimalFormat("#0"))));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        jPanel3.add(eLFTFRenspaVenta, gridBagConstraints);
        eLFTFRenspaVenta.makeEditable(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new DecimalFormat("#0"))));

        jBAceptarVenta.setText("Aceptar");
        jBAceptarVenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAceptarVentaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
        jPanel3.add(jBAceptarVenta, gridBagConstraints);

        jLabel23.setText("Agregar:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        gridBagConstraints.insets = new java.awt.Insets(6, 15, 0, 0);
        jPanel3.add(jLabel23, gridBagConstraints);

        jFTFAgregar.setColumns(10);
        try {
            jFTFAgregar.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("UU###U###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFTFAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFTFAgregarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
        jPanel3.add(jFTFAgregar, gridBagConstraints);

        jBResetearVenta.setText("Resetear");
        jBResetearVenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBResetearVentaActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 5);
        jPanel3.add(jBResetearVenta, gridBagConstraints);

        jBImprimir.setText("Imprimir");
        jBImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBImprimirActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(10, 5, 0, 5);
        jPanel3.add(jBImprimir, gridBagConstraints);

        jLabel1.setFont(org.tri.gui.view.ViewConstants.underlinedLabelFont);
        jLabel1.setText("Datos de la venta:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        jPanel3.add(jLabel1, gridBagConstraints);

        getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);
        getContentPane().add(filler9, java.awt.BorderLayout.SOUTH);
        getContentPane().add(filler4, java.awt.BorderLayout.WEST);
        getContentPane().add(filler8, java.awt.BorderLayout.NORTH);
        getContentPane().add(filler3, java.awt.BorderLayout.EAST);
    }// </editor-fold>//GEN-END:initComponents

    private void jBAceptarVentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAceptarVentaActionPerformed
        
        //me fijo si los campos editables han sido modificados
        if (eLFTFDtaVenta.isModified() || eLFTFRenspaVenta.isModified()
                || eLTFDestinatario.isModified() || listModified) {

            //seteo los campos
            if(eLFTFDtaVenta.getText().equals(""))
                venta.setNroDta( 0 );
            else
                venta.setNroDta(Long.parseLong(eLFTFDtaVenta.getText()));
            
            venta.setDestinatario(eLTFDestinatario.getText());
            
            if(eLFTFRenspaVenta.getText().equals(""))
                venta.setRenspaDestinatario( 0 );
            else
                venta.setRenspaDestinatario(Long.parseLong(eLFTFRenspaVenta.getText()));

            //agrego los animales nuevos
            DefaultListModel modelo = (DefaultListModel) jLCaravanasVenta.getModel();
            for (Object o : modelo.toArray()) {
                venta.agregarAnimal((Animal) o);
            }
            
            //desligo los animales quitados en caso de que los halla
            if(animalesEliminados.size() > 0)
                venta.eliminarAnimales(animalesEliminados);   
            
            //almaceno la venta
            //seteo el error a false por si ocurrio un error anteriormente
            errorPersist = false;

            //realizamos las tareas de almacenado en un thread aparte
            PersistenceWorker worker = new PersistenceWorker(venta);

            worker.addPersistenceListener( this );

            worker.execute();

        }

        this.dispose();

    }//GEN-LAST:event_jBAceptarVentaActionPerformed

    private void jFTFAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFTFAgregarActionPerformed
        StringBuilder error = new StringBuilder();

        //busco que la caravana ingresada exista
        BusquedaAnimal busqueda = new BusquedaAnimal();
        busqueda.porEstablecimiento( venta.getEstablecimiento() );
        //me fijo que halla algo en el campo caravana
        try {
            jFTFAgregar.commitEdit();
            busqueda.porCaravana(jFTFAgregar.getText());
        } catch (ParseException pE) {
            error.append("- El campo \"Caravana\" no fué completado.");
        }
        busqueda.porVendido( false );
        busqueda.porViva( true );

        //si no hay errores
        if (error.length() == 0) {
            //si existe un resultado lo agrego a la lista
            if (busqueda.resultadoUnico() != null) {
                caravanas.addElement(busqueda.resultadoUnico());
                jLCaravanasVenta.setModel(caravanas);
                listModified = true;
                //le sumo uno al label de cantida
                jLCantidadAnimalesVenta.setText(String.valueOf(Integer.parseInt(jLCantidadAnimalesVenta.getText())+1));
            } else {
                error.append(" - La caravana ingresada no existe o esta vendida");
                
                //muestro el error
                JOptionPane.showMessageDialog(
                    this, error.toString(),
                    "Error",
                    JOptionPane.WARNING_MESSAGE);
            }

        } else {
            JOptionPane.showMessageDialog(
                    this, error.toString(),
                    "No se completaron todos los campos",
                    JOptionPane.WARNING_MESSAGE);
        }

        //seteo el campo nuevamente a cero
        jFTFAgregar.setText("");
        
    }//GEN-LAST:event_jFTFAgregarActionPerformed

    private void jBResetearVentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBResetearVentaActionPerformed
        //reseteo los labels modificables al valor anterior
        eLFTFDtaVenta.resetToDefault();
        eLFTFRenspaVenta.resetToDefault();
        eLTFDestinatario.resetToDefault();
        jLCantidadAnimalesVenta.setText(String.valueOf(venta.getCantidadAnimales()));

    }//GEN-LAST:event_jBResetearVentaActionPerformed

    private void jMIQuitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIQuitarActionPerformed
        //agrego el animal retirado a una lista para mas tarde desligarlo de la venta
        animalesEliminados.add( (Animal)jLCaravanasVenta.getSelectedValue() );
        
        //quito el animal de la lista
        caravanas.remove(jLCaravanasVenta.getSelectedIndex());
        listModified = true;
        
        //le resto uno al label de cantidad
        jLCantidadAnimalesVenta.setText(String.valueOf(Integer.parseInt(jLCantidadAnimalesVenta.getText())-1));
        
    }//GEN-LAST:event_jMIQuitarActionPerformed

    private void jBImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBImprimirActionPerformed
        //mando a imprimir el formulario asociado a la venta seleccionada
        try{
            TRIHelper.guardarEImprimir( (Venta) venta );
            
        }catch(Exception e){
            JOptionPane.showMessageDialog( null,
                                           "El programa no pudo abrir el "
                                           + "archivo para imprimir.\n "
                                           + "Deberá abrirlo manualmente.",
                                           "Información",
                                           JOptionPane.INFORMATION_MESSAGE );
            
        }
            
    }//GEN-LAST:event_jBImprimirActionPerformed

    private void jScrollPane3MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane3MousePressed
        
    }//GEN-LAST:event_jScrollPane3MousePressed

    private void jScrollPane3MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane3MouseReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_jScrollPane3MouseReleased

    private void jLCaravanasVentaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLCaravanasVentaMousePressed
        //seleccionamos la celda bajo el mouse
        if ( SwingUtilities.isRightMouseButton( evt ) ){
            jLCaravanasVenta.setSelectedIndex(jLCaravanasVenta.locationToIndex(evt.getPoint()));
            
        }
    }//GEN-LAST:event_jLCaravanasVentaMousePressed

    private void jLCaravanasVentaMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLCaravanasVentaMouseReleased
        jLCaravanasVentaMousePressed( evt );
    }//GEN-LAST:event_jLCaravanasVentaMouseReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.tri.swing.EditableLabelFTF eLFTFDtaVenta;
    private org.tri.swing.EditableLabelFTF eLFTFRenspaVenta;
    private org.tri.swing.EditableLabelTF eLTFDestinatario;
    private javax.swing.Box.Filler filler3;
    private javax.swing.Box.Filler filler4;
    private javax.swing.Box.Filler filler8;
    private javax.swing.Box.Filler filler9;
    private javax.swing.JButton jBAceptarVenta;
    private javax.swing.JButton jBImprimir;
    private javax.swing.JButton jBResetearVenta;
    private javax.swing.JFormattedTextField jFTFAgregar;
    private javax.swing.JLabel jLCantidadAnimalesVenta;
    private javax.swing.JList jLCaravanasVenta;
    private javax.swing.JLabel jLCategoria;
    private javax.swing.JLabel jLEstablecimientoVenta;
    private javax.swing.JLabel jLFechaVenta;
    private javax.swing.JLabel jLTipoMovimientoVenta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JMenuItem jMIQuitar;
    private javax.swing.JPopupMenu jPMQuitar;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane3;
    // End of variables declaration//GEN-END:variables

//implementación del método donePersisting de la interfaz persistenceListener
     @Override
     public void donePersisting() {
        //si hay errores, mostramos el mensaje y salimos.
        if ( errorPersist ) {
            JOptionPane.showMessageDialog(null, "Error al intentar almacenar los cambios" ,
                                          "Error" , JOptionPane.ERROR_MESSAGE);
                
        }//end if
        else{
        
            //muestro el mensaje de que ha sido eliminado correctamente
            JOptionPane.showMessageDialog(null, "Se han almacenado los cambios satisfactoriamente" ,
                                          "Mensaje", JOptionPane.INFORMATION_MESSAGE);
        }

     }//end método donePersisting

     //implementación del método errorPersisting de la interfaz persistenceListener
     @Override
     public void errorPersisting( ExecutionException ex ) {
        errorPersist = true;

            //mostrar error

     }//end método errorPersisting
     

}
